package com.itheima.service.impl;

import com.itheima.dao.Repository.BusUserResponsitory;
import com.itheima.model.domain.BusUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusUserService {
    @Autowired
    private BusUserResponsitory busUserRepository;
    public List<BusUser> findAll(){
        return busUserRepository.findAll();
    }


    public BusUser loginConfirm(String username, String password) {
        return busUserRepository.loginConfirm(username,password);
    }

    public BusUser save(BusUser busUser) {
        return busUserRepository.save(busUser);
    }

    public BusUser getOne(int id){
        return busUserRepository.getOne(id);
    }

    public BusUser findUserByName(String user_name){
        BusUser busUser = busUserRepository.findUserByName(user_name);
        return busUser;
    }

    public List<BusUser> searchByUsername(String keyword) {
        return busUserRepository.findByUsernameContaining(keyword);
    }

    public void deleteBusUserById(int id){
        busUserRepository.deleteBusUserByUserId(id);
    }

    public BusUser findUserById(int id){
        BusUser busUser=busUserRepository.findUserById(id);
        return busUser;
    }

    public void updateBusUserInfo(BusUser busUser){
        busUserRepository.updateBusUserInfo(busUser);
    }

}
